<?php
/**
 * Goods
 * Created by Veyron
 * motto:现在的拼搏 为了更好的明天
 * day:  2020/2/8
 * Time: 21:02
 */

namespace app\admin\controller;
use app\common\business\SpecsValue as SpecsValueBus;

class SpecsValue extends AdminBase
{
    public function save(){
        $specsId = input('specs_id',0,'intval');
        $name    = input('name',0,'trim');
        $data = [
            'specs_id'  => $specsId,
            'name'      => $name
        ];
        $specsValueValidate = new  \app\admin\validate\SpecsValue();
        if(!$specsValueValidate->check($data)){
            return show(config('status.error'),$specsValueValidate->getError());
        }
        $id = (new SpecsValueBus())->add($data);
        if(!$id){
            return show(config('status.error'),'新增失败');
        }
        return show(config('status.success'),'OK',['id'=>$id]);
    }
    public function getBySpecsId(){
        $specsId = input('specs_id',0,'intval');

        if(!$specsId){
            return show(config('status.success'),'没有数据');
        }
        $result = (new SpecsValueBus())->getBySpecsId($specsId);
        return show(config('status.success'),'OK',$result);
    }
    public function delete(){
        $id = input('id',0,'intval');
        if(!$id){
            return show(config('status.success'),'没有数据');
        }
        $result = (new SpecsValueBus())->delete($id);
        return show(config('status.success'),'OK',$result);
    }
}
